﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAL.Entiteti;

namespace KSZ
{
    public partial class SearchIgraca : Form
    {
        List<Control> lista_kontrola = new List<Control>();
        List<Igrac> lista_igraca = new List<Igrac>();
        public SearchIgraca()
        {
            InitializeComponent();
        }

        private void SearchIgraca_Load(object sender, EventArgs e)
        {
            DAL.DAL d1 = DAL.DAL.Instanca;
            d1.kreirajKonekciju("localhost", "mydb", "root", "FCChelsea1");
            DAL.DAL.IgracDAO cd1 = new DAL.DAL.IgracDAO();
            lista_igraca = cd1.getAll();
            d1.terminirajKonekciju();
            foreach (Igrac i in lista_igraca)
            {
                flowLayoutPanel1.Controls.Add(new IgracControl(i));
                flowLayoutPanel1.Refresh();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            DAL.DAL d1 = DAL.DAL.Instanca;
            d1.kreirajKonekciju("localhost", "mydb", "root", "FCChelsea1");
            DAL.DAL.IgracDAO cd1 = new DAL.DAL.IgracDAO();
            lista_igraca = cd1.getByExample(textBox1.Text);
            d1.terminirajKonekciju();
            foreach (Igrac i in lista_igraca)
            {
                flowLayoutPanel1.Controls.Add(new IgracControl(i));
                flowLayoutPanel1.Refresh();
            }
            
        }
    }
}
